import HTMLTestRunnerPlugins
import time
import unittest

# 测试文件路径
case_dir = "./case"
# 测试报告路径
report_dir = "./report"
# 命名测试报告文件名
now = time.strftime("%Y-%m-%d %H-%M-%S ")
report_file = open(report_dir + '\\' + now + 'HTMLReport.html', 'wb')
# 构造测试集
discover = unittest.defaultTestLoader.discover(case_dir, pattern="test*.py")
# 创建runner
runner = HTMLTestRunnerPlugins.HTMLTestRunner(
    stream=report_file, verbosity=2, title="ECShop电子商城自动化测试项目", description="group: 第四小组", retry=0
)
# 运行测试用例
runner.run(discover)
